import jwt
from django.conf import settings

def jwt_dic(user):
    _property={
        'id':user.id,
        'username':user.username,
    }
    token=jwt.encode(payload=_property,key=settings.SECRET_KEY,algorithm='HS256')
    return token

def parse_token(token):
    '''校验token'''
    payload=jwt .decode(token,key=settings.SECRET_KEY,algorithms=['HS256'])
    return payload